home *** CD-ROM | disk | FTP | other *** search
/ PC Advisor 1999 December / PC Advisor 1999-12 Issue 51 CD.iso / draw / Draw 4 tl / data1.cab / Prog_(US) / DES_PS.PRE < prev    next >
Encoding:
Text File  |  1999-07-21  |  27.6 KB  |  1,121 lines

  1. %-----------------------------------------------------------------------------
  2. % 9999.17 GST 194 - PostScript Preamble file for GST DesignWorks
  3. %-----------------------------------------------------------------------------
  4. % This file is inserted as the prolog when Artwork saves an EPSF file.
  5. % The program generates the initial structure comments required by EPSF
  6. % and strips comments from this file as it merges it into its output.
  7. % The main part of the job is put between the 'EndSetup' and 'Trailer' lines.
  8. %-----------------------------------------------------------------------------
  9. % Naming conventions: 
  10. % Names in all lowercase are executable procedures, like built-in postscript
  11. % procedures. Names with the first letter capitalised are variables. Names 
  12. % ending in a question mark are boolean: they can have values T or F
  13. %-----------------------------------------------------------------------------
  14. % 0.30 18.Aug.98
  15. % add calligraphic lines for dwk4
  16. %
  17. % 0.29 1.July.94
  18. % as shipped with dwk2, 2.5, 3, 3.5
  19. %
  20. % NOTE: comments are stripped before printing!
  21. %-----------------------------------------------------------------------------
  22. %
  23. % ArtProcsDict contains all the procedures defined in this prolog
  24. % and must also have enough room for special postscript fill & line style procs.
  25. % ArtVarsDict contains all the variables etc used by the procedures.
  26.  
  27. /ArtProcsDict 160 dict def  
  28. /ArtVarsDict 100 dict def  
  29.  
  30. %---- optional jobtimeout 
  31. ArtVarsDict begin 
  32.    /Timeout 0 def 
  33. end
  34.  
  35. ArtProcsDict begin
  36.  
  37. %----- abbreviations -----%
  38.  
  39.  /bd { bind def } bind def
  40.  /ed { exch def } bd
  41.  /np /newpath load def
  42.  /cp /closepath load def
  43.  /gs { /SavePrint? Print? def gsave } bd
  44.  /gr { /Print? SavePrint? def grestore } bd
  45.  
  46.  /SS{}def
  47.  /RS{}def
  48.  /SM{}def
  49.  
  50. %----- misc tiny routines -----%
  51.  
  52. % specialscreen? returns YES if screen frequency <= 30
  53.  /specialscreen? { currentscreen pop pop 30 lt } bd
  54.  /min{2 copy gt{exch}if pop}bd % minimum of top 2 items on stack
  55.  /max{2 copy lt{exch}if pop}bd % maximum ditto
  56.  /maxof4 { 3{max}repeat } bd
  57.  /pt { 1000 mul 72 div } bd % converts points
  58.  /beginlayer { pop /LayerSave save def } bd %% layer number ignored
  59.  /endlayer { LayerSave restore } bd
  60.  
  61.  
  62. %----- path construction -----%
  63.  
  64. % P: adjusts positions of thin lines 
  65.  /p { transform round .4 add exch round .4 add exch itransform } bd
  66.  /c { p curveto } bd /m { p moveto } bd /l { p lineto } bd
  67.         
  68.  
  69. %---------- Colour handling ----------%
  70. %
  71. % define setcmykcolor if not implemented in printer. 
  72.  
  73. /mysetcmykcolor { % convert CMYK to RGB for monochrome printer
  74.   4 1 roll
  75.   3 {
  76.     3 index add 1 exch sub
  77.     dup 0 lt{pop 0}if
  78.     3 1 roll
  79.   } repeat
  80.   setrgbcolor pop
  81. } bd
  82.  
  83. /initcmykcolor {
  84.   /setcmykcolor where dup
  85.   /BwPrinter? exch not def
  86.   { 
  87.     pop 
  88.   }{
  89.     /setcmykcolor /mysetcmykcolor load def
  90.   } ifelse
  91. } bd
  92.  
  93.  
  94. %----- SETCMYK -----%
  95. % setcmyk is a low-level routine, called whether or not the 
  96. % printer supports colour.
  97. % It is at this level that we perform process colour separation.
  98. % We save the current CMYK setting, and routine currentcmyk can
  99. % be called to enquire the setting.
  100.  
  101. /setcmyk { 
  102.   4 copy SaveCmyk astore pop 
  103.   Comp? {               % printing a monochrome or colour composite
  104.     BwPrinter? specialscreen? and
  105.     {
  106.         % printing a special screen on a monochrome composite
  107.         % don't convert cmyk, as we'll end up with stripes or dots
  108.         % which are too small: convert the largest process colour
  109.         % component to gray. (Still not completely correct)
  110.         maxof4 1 exch sub setgray
  111.     }{
  112.       setcmykcolor 
  113.     } ifelse
  114.   }{
  115.     SpotSep? {          % if printing a spot-colour separation
  116.       blank pop         % print blank (clear or white, depending on overprint flag) 
  117.     }{                  % else printing a a process separation
  118.       4 Separation roll % bring one sep to top
  119.       dup 0 eq { 
  120.         blank pop 
  121.       }{ 
  122.         1 exch sub setgray 
  123.       } ifelse
  124.     } ifelse
  125.     pop pop pop         % clear c,m,y from stack
  126.   } ifelse
  127. } bd
  128.  
  129.  
  130. /currentcmyk {
  131.   SaveCmyk aload pop
  132. } bd
  133.  
  134.  
  135. %----- APPLYTINT -----%
  136. %
  137. % This is a lower-level colour interface
  138. % which can apply a percentage tint to a set
  139. % of CMYK percentage values.
  140. %
  141. % stack: t% c% m% y% k%
  142.  
  143. /applytint {
  144.   4{ 
  145.     4 index mul 
  146.     10000 div 
  147.     4 1 roll 
  148.   }repeat 
  149.   setcmyk 
  150.   pop 
  151. } bd
  152.  
  153.  
  154.  
  155. /blank { 
  156.   1 setgray 
  157.   /Print? OverPrint? not def 
  158.   0 0 0 0 SaveCmyk astore pop
  159. } bd
  160.  
  161.  
  162. /setgraytint {
  163.   dup 0 eq { OverPrint? not } { T } ifelse 
  164.   /Print? ed
  165.   dup /SpotTint ed
  166.   100 div 1 exch sub setgray
  167. } bd
  168.  
  169.  
  170.  
  171.  
  172. %----- COLPROCS -----%
  173. % Colprocs is a dictionary containing different procedures for 
  174. % setcolour to execute, depending on the type of the object 
  175. % on top of the stack when setcolour is called.
  176. % Colours is a dictionary of user-defined colours, indexed by name,
  177. % containing 2-level [ [C M Y K] spot? ] arrays with values in range 0-100
  178.  
  179. /Colprocs 4 dict def 
  180. Colprocs begin
  181.  
  182.   /arraytype {                          % [ C M Y K ] process colour mix
  183.       100 exch aload pop applytint      % apply 100% tint to the mix
  184.   } bd
  185.  
  186.   % perform spot-colour separation 
  187.   /nametype {                   % stack: tint name
  188.     dup Colours exch get        % tint name [ [ C M Y K ] Spot? ]
  189.     1 get not Comp? or {        % if not a spot colour, or printing composite
  190.       Colours exch get          % tint [ [ C M Y K ] Spot? ]
  191.       0 get aload pop           % tint c m y k
  192.       applytint 
  193.     }{                          % else spot colour & not composite printout
  194.       SpotSep? {                % if printing a spot separation...
  195.         Separation eq {            % is spot colour same as this separation?
  196.           setgraytint           % if so, set percentage tint
  197.         }{
  198.           pop blank             % wrong spot sep: print nothing
  199.         } ifelse
  200.       }{
  201.         pop pop blank           % printing a process sep: print nothing
  202.       } ifelse
  203.     } ifelse
  204.   } bd
  205.  
  206.   /integertype {                % apply percentage tint to black
  207.     0 0 0 100 applytint 
  208.   } bd
  209.  
  210.   /realtype /integertype load def
  211. end % Colprocs
  212.  
  213.  
  214.  
  215. %----- SETCOLOUR -----%
  216. %
  217. % This routine is the top-level color interface. 
  218. % It can be called in three different ways:
  219. %   number      SETCOLOUR --  % number is %black, 0=white 100=black
  220. %   [ 4-array ] SETCOLOUR --  % array contains C M Y K percentages
  221. %   number name SETCOLOUR --  % percentage tint of a named colour
  222.  
  223. /setcolour { 
  224.   /Print? T def
  225.   /SpotTint 0 def % preset spot colour tint value to zero
  226.   dup type Colprocs exch get exec 
  227. } bd
  228.  
  229.  
  230.  
  231. %----- FILL and STROKE -----%
  232. %
  233. % Winding? is a boolean which selects whether we use the winding-number fill
  234. % or the even-odd fill algorithm. Print? is a boolean used to enable or 
  235. % disable fill and stroke when overprinting separations, set by setcolour 
  236. % and blank.
  237.  
  238.  /ovp { /OverPrint? ed } bd
  239.  /wif { /Winding? T def } bd
  240.  /eof { /Winding? F def } bd
  241.  
  242.  /~stroke { Print? { stroke } if } bd
  243.  /_stroke { setcolour ~stroke } bd
  244.  /~fill { Print? { Winding? { fill } { eofill } ifelse } if } bd
  245.  /_fill { setcolour ~fill } bd
  246.  /_clip { Winding? { clip } { eoclip } ifelse } bd
  247.  
  248.  /sml { 2 div sin 1 exch div setmiterlimit } bd
  249.  /sline { setlinewidth setlinejoin setlinecap } bd
  250.  /li { Lines exch get exec } bd
  251.  /fi { Fills exch get exec } bd
  252.  
  253.  
  254. % stack: factor% angle-deg
  255. /calstroke {
  256.   /Theta ed 
  257.   /PenScale ed 
  258.   setcolour
  259.   gs currentlinewidth Theta rotate 1 1 PenScale mul 100 div scale setlinewidth ~stroke gr
  260. } bd
  261.  
  262. %----- GROUPS -----%
  263.  
  264.  /bg { gsave concat } bd % matrix BG -- 
  265.  /eg { grestore } bd 
  266.  /bgd { gsave defmat setmatrix } bd
  267.  
  268.  
  269. %----- Utility Routines -----%
  270.  
  271.  /getbox { /Top ed /Right ed /Bottom ed /Left ed } bd 
  272.  
  273.  /arcpop { arcto 4 { pop } repeat } bd
  274.  
  275.  
  276.  
  277. %----- basic shapes: ROUND BOX -----%
  278.  
  279. /shape_rbox {
  280.   /Rad ed
  281.   getbox
  282.   matrix currentmatrix
  283.     exch concat
  284.     np Left Right add 2 div Top p moveto % top centre
  285.     Right Top p Right Bottom p Rad arcpop
  286.     Right Bottom p Left Bottom p Rad arcpop
  287.     Left Bottom p Left Top p Rad arcpop
  288.     Left Top p Right Top p Rad arcpop cp 
  289.   setmatrix
  290. } bd
  291.  
  292.  
  293.  
  294. %----- basic shapes: BOX -----%
  295. /boxpath {
  296.   np Left Top m Right Top l
  297.   Right Bottom l Left Bottom l cp
  298. } bd
  299.  
  300. /shape_box {
  301.   getbox
  302.   matrix currentmatrix
  303.     exch concat boxpath
  304.   setmatrix
  305. } bd
  306.  
  307.  
  308. /clip_box { getbox boxpath eoclip } bd
  309.  
  310.  
  311.  
  312. %----- basic shapes: ELLIPSE -----%
  313.  
  314. /shape_ellipse {
  315.   getbox
  316.   matrix currentmatrix 
  317.     exch concat
  318.     % map unit circle to bounding box
  319.     Left Top translate
  320.     Right Left sub Bottom Top sub scale
  321.     np .5 .5 .5 0 360 arc cp
  322.   setmatrix
  323. } bd
  324.  
  325.  
  326. %----- IMAGES -----%
  327.  
  328. /artimage {
  329.   gs
  330.     /Bgd? exch def
  331.     /Mask? exch def
  332.     /Bits exch def 
  333.     /Height exch def
  334.     /Width exch def
  335.     getbox concat 
  336.  
  337.     Bgd? { setcolour boxpath wif ~fill } if
  338.  
  339.     Left Top translate 
  340.     Right Left sub 
  341.     Bottom Top sub scale
  342.  
  343.     Mask? {   
  344.       setcolour
  345.         Width Height true [ Width 0 0 Height 0 0 ] 
  346.         { currentfile ImageBuff readhexstring pop }
  347.       imagemask
  348.     }{  Width Height Bits [ Width 0 0 Height 0 0 ] 
  349.         { currentfile ImageBuff readhexstring pop }
  350.       image
  351.     } ifelse
  352.   gr
  353. } bd    
  354.  
  355.  
  356. /densitylookup {
  357.    densitygreys 1 sub mul cvi  % convert input grey level to integer
  358.    densityarray exch get   % lookup value (range 0..2000)
  359.    1000 div             % convert to density 0.0-2.0
  360.    neg 10 exch exp      % reflectance = 10 ^ -density
  361. } bd
  362.  
  363. /palettelookup {
  364.    palettecols 1 sub mul cvi  % convert input grey level to integer
  365.    palettearray exch get   % lookup value (range 0..1000)
  366.    1000 div             % convert to reflectance 0..1
  367. } bd
  368.  
  369. /artcolimage {
  370.   gs
  371.     /Proc exch load def 
  372.     /Height ed /Width ed
  373.     getbox concat            
  374.     Left Top translate 
  375.     Right Left sub 
  376.     Bottom Top sub scale
  377.  
  378.     /Im? T def
  379.     /Wn Width def
  380.  
  381.     Width Height 8 [ Width 0 0 Height 0 0 ] 
  382.     /Proc load 
  383.     false 3 colorimage
  384.  
  385.     gr
  386. } bd    
  387.  
  388. /img4 {
  389.  Im? {
  390.    % read one byte from the file
  391.    currentfile ImageBuff readhexstring pop 
  392.    0 get -4 bitshift
  393.  }{
  394.    ImageBuff 0 get
  395.  }ifelse
  396.  
  397.  %--- see if we're at the end of a raster line
  398.  Wn 1 sub dup 0 eq { pop Width T }{ Im? not } ifelse
  399.  /Im? ed /Wn ed
  400.  
  401.  % use result as index into palette
  402.  15 and palettearray exch get 
  403. } bd
  404.  
  405.  
  406. /img8 {
  407.    currentfile ImageBuff readhexstring pop % read one byte from the file
  408.    0 get palettearray exch get % use that as index into palette
  409. } bd
  410.  
  411. /img24 {
  412.    currentfile ImageRgbBuff readhexstring pop % read 3 bytes from the file
  413. } bd
  414.  
  415.  
  416. %----- normalised transfer function -----%
  417.  
  418. /normalise
  419. {
  420.   mark
  421.   1.0 1.0 .98 .9 .82 .68 
  422.   .56 .48 .28 .1 .06 .0                 % i [ nvalues
  423.   counttomark                           % i [ nvalues n
  424.   dup 3 add -1 roll exch                % [ nvalues input n
  425.   2 sub mul                             % [ nvalues j     % j = (n-2)*i k=floor(j)
  426.   dup floor cvi                         % [ nvalues j k
  427.   dup 3 1 roll sub                      % [ nvalues k j-k
  428.   exch dup                              % [ nvalues j-k k k
  429.   3 add index exch 2 add index dup      % [ nvalues j-k table[k+1] table[k] table[k]
  430.   4 1 roll                              % [ nvalues table[k] j-k table[k+1] table[k]
  431.   sub mul add                           % [ nvalues result    % result = ( table[k] + (j-k)*(table[k+1]-table[k]) )
  432.   counttomark 1 add 1 roll              % result [ nvalues
  433.   cleartomark                           % result
  434. } bd
  435.  
  436.  
  437. /?Negative {} bd % if printing negative, this procedure changes
  438.  
  439. /neg_transfer { 
  440.   /?Negative { 1 exch sub } bd 
  441.   {  ?Negative normalise DefTran } bind settransfer   
  442.   gs clippath 1 setgray fill gr              % then fill with white
  443.   
  444. } bd
  445.  
  446. %----- Special Effects: Flatten Path -----%
  447. %
  448. % flatten path, adjust 'setflat' until it works.
  449. % no parameters, no output. NOTE: this leaves a 'gs' in effect
  450.  
  451. /flatclip { 
  452.   currentflat
  453.   { 
  454.     gs
  455.     { flattenpath _clip } stopped not {exit}if
  456.     % ie, if not stopped due to error, exit loop
  457.     
  458.     % but if the error was other than limitcheck, stop now!
  459.     $error /errorname get /limitcheck ne { stop } if
  460.  
  461.     % if flatness gets too high, give up
  462.     currentflat 80 gt { exit } if
  463.     
  464.     % try again with flatter paths
  465.     gr currentflat 1.1 mul 1 add setflat
  466.   }loop
  467.   setflat
  468. } bd
  469.  
  470. /flatp { 
  471.   currentflat
  472.   { {flattenpath} stopped not {exit}if
  473.     currentflat 1 add setflat
  474.   }loop
  475.   setflat
  476. } bd
  477.  
  478.  
  479.  
  480. %----- Special Effects: Clip to Path -----%
  481. %
  482. % Also computes bounding box and width and height.
  483. % NOTE: flatclip saves graphics state
  484.  
  485. /clipper {
  486.   pathbbox flatclip
  487.   /Bottom ed /Right ed /Top ed /Left ed
  488.   Right Left sub /Width ed
  489.   Bottom Top sub /Height ed
  490. } bd
  491.  
  492.  
  493.  
  494.  
  495. %----- Example of a special fill routine -----%
  496.  
  497. /examplefill {
  498.   clipper %gs implied
  499.     Left Top translate
  500.     % insert commands to fill area from (0,0) to (Width,Height)
  501.     Width Height scale
  502.     % or insert commands to fill unit square
  503.   gr
  504. } bd
  505.  
  506.  
  507.  
  508. %----- Graduated Fill Support Code -----%
  509.  
  510. /GradFillDict 30 dict def
  511.  
  512. /GrayProcs [ 
  513.   {} % 0: radial
  514.   {dup mul} bind % 1: spherical 
  515.   {} % 2
  516.   {} % 3: linear
  517.   {9 mul 1 add log} bind % 4: logarithmic
  518.   {dup 1 exch sub mul 4 mul} bind % 5: cylindrical 
  519. ] def
  520.  
  521. /grayconv { % start diff ingray GRAYCONV outgray 
  522.   GrayProcs GradType get exec
  523.   mul add
  524. } bd
  525.  
  526.  
  527. /grad_common_init {
  528.   %---- initialise variables in local dictionary
  529.  
  530.   % convert start colour to CMYK and get values
  531.   setcolour 
  532.   SpotSep? not {
  533.     currentcmyk 
  534.     /StartK ed /StartY ed /StartM ed /StartC ed
  535.   } if
  536.   /StartT SpotTint def
  537.  
  538.   % do the same for the end colour
  539.   setcolour 
  540.   SpotSep? not {
  541.     currentcmyk
  542.     /EndK ed /EndY ed /EndM ed /EndC ed
  543.   } if
  544.   /EndT SpotTint def 
  545.  
  546.   % replace End with End-Start
  547.   SpotSep? not {
  548.     /EndC EndC StartC sub def
  549.     /EndM EndM StartM sub def
  550.     /EndY EndY StartY sub def
  551.     /EndK EndK StartK sub def
  552.   } if
  553.   /EndT EndT StartT sub def
  554.  
  555.  
  556.   % If printing colour separations, if the separation has
  557.   % the same tint for the start and end of the grad fill,
  558.   % treat it as a solid fill to save time.
  559.  
  560.   /SolidFill? F def
  561.  
  562.   Comp? not {           % not printing a composite - separations
  563.  
  564.     SpotSep? {          % printing a spot colour sep
  565.       StartT setgraytint
  566.       EndT 0 eq /SolidFill? ed
  567.     }{                  % printing a process sep
  568.       mark
  569.       StartC StartM StartY StartK 4 Separation roll
  570.       100 mul setgraytint % 0.22
  571.  
  572.       EndC EndM EndY EndK 4 Separation roll
  573.       0 eq /SolidFill? ed
  574.       
  575.       cleartomark
  576.     } ifelse
  577.  
  578.   } if
  579. } bd
  580.  
  581.  
  582. /grad_common_middle {
  583.   /X ed
  584.   SpotSep? {
  585.     StartT EndT X grayconv
  586.     setgraytint 
  587.   }{
  588.     StartC EndC X grayconv
  589.     StartM EndM X grayconv
  590.     StartY EndY X grayconv
  591.     StartK EndK X grayconv
  592.     setcmyk
  593.   } ifelse
  594. } bd
  595.  
  596.  
  597.  
  598.  
  599. %----- Graduated Fill: linear, logarithmic, cylindrical -----%
  600. %
  601. % parameters: angle type startcolour endcolour
  602. % each colour can be either a number (for a black tint)
  603. % a number and a name, or an array of four values: 
  604. % the same as setcolour.
  605. % type: 3=linear 4=logarithm 5=cylinder
  606.  
  607. /linfill {
  608.   GradFillDict begin
  609.   grad_common_init
  610.   /GradType ed
  611.   neg /Theta ed
  612.   /Steps GradType 3 ne { 200 } { 100 } ifelse def
  613.   % also uses Top Bottom Left Right Width Height in dictionary
  614.  
  615.   SolidFill? {
  616.  
  617.     ~fill       % separation, and fill is solid for this sep
  618.   }{
  619.  
  620.     %---- prepare to fill to clipping path 
  621.     %     and setup transformation matrix
  622.     gs
  623.       Theta rotate 
  624.       clipper %gs implied
  625.       Left Top translate
  626.       Width Height scale
  627.       1 Steps 1 add div setlinewidth
  628.  
  629.       0 1 Steps { 
  630.         dup Steps div
  631.  
  632.         grad_common_middle
  633.  
  634.         newpath
  635.           .5 add 
  636.           Steps 1 add 
  637.         div 0
  638.         moveto 
  639.  
  640.         0 1 rlineto
  641.         ~stroke
  642.  
  643.       } bind for
  644.     gr gr
  645.  
  646.   }ifelse
  647.  
  648.   end
  649. } bd
  650.  
  651.  
  652. %----- Radial/Spherical Graduated Fill -----%
  653. %
  654. % stack: type startcolour endcolour
  655. % type: 0=radial, 1=spherical
  656.  
  657. /radfill { 
  658.   GradFillDict begin
  659.   grad_common_init
  660.   /GradType ed
  661.   /Steps GradType 0 ne { 200 } { 100 } ifelse def
  662.  
  663.   SolidFill? {
  664.     ~fill       % separation, and fill is solid for this sep
  665.   }{
  666.  
  667.     clipper %gs implied
  668.       Left Right add 2 div Top Bottom add 2 div translate % centre
  669.       Width dup mul Height dup mul add sqrt 2 div dup scale % half diagonal
  670.       Steps -1 1 { % loop to fill unit circle centred on origin
  671.         /Rad exch Steps div def
  672.  
  673.         Rad grad_common_middle
  674.  
  675.         np 0 Rad moveto 0 0 Rad 0 360 arc cp
  676.         ~fill
  677.       } bind for
  678.     gr
  679.  
  680.   } ifelse
  681.  
  682.   end
  683. } bd
  684.  
  685. %----- Arrowheads -----------
  686.  
  687. /ArrowProcs [
  688. {} 
  689. {np 0 25 m 50 0 l 0 -25 l cp fill }   
  690. {np 0 25 m 50 0 l 0 -25 l cp stroke } 
  691. {np 0 0 m -10 25 l 50 0 l -10 -25 l cp fill }
  692. {np 5 0 m -5 25 l 50 0 l -10 -25 l cp stroke }
  693. {np -45 25 m 5 0 l -45 -25 l stroke }
  694. {np 0 25 m 0 -25 l stroke }
  695. {np 2 setlinejoin -50 25 m 0 0 l -50 -25 l 0 25 m 0 -25 l stroke }
  696. {np 50 25 m 0 0 l 50 -25 l stroke }
  697. {np 100 25 m 50 0 l 100 -25 l 50 0 m 0 0 l 50 25 m 0 0 l 50 -25 l stroke }
  698. {np 100 25 m 50 0 l 100 -25 l 45 -25 l 0 -5 l 0 5 l 45 25 l cp fill }
  699. ] def
  700.  
  701. % type dx dy scale x y arrow
  702.  
  703. /arrow {
  704.   gs
  705.     translate 
  706.     dup 20 lt { pop 20 } if
  707.     10 div dup scale 
  708.     exch atan 180 add rotate
  709.     0 0 10 sline
  710.     Print? {
  711.       ArrowProcs exch get exec
  712.     }{
  713.       pop
  714.     } ifelse
  715.     gr
  716. } bd
  717.  
  718.  
  719.  
  720. %----- Tiled Fill -----------
  721.  
  722. /TiDict 20 dict def
  723.  
  724. /tipos {        % pos wid
  725.   dup           % pos wid wid
  726.   3 1 roll      % wid pos wid
  727.   div floor mul % pos'
  728. } bd
  729.  
  730. /_tile { % dx dy proc scaledwidth scaledheight scale(percent) angle
  731.   TiDict begin
  732.   /TiAngle ed 
  733.   100 div /Tscale ed
  734.   Tscale div /TiHgt ed 
  735.   Tscale div /TiWid ed 
  736.   /TiProc ed
  737.   % leave just dx & dy on stack
  738.  
  739.   gs 1 setgray ~fill gr % 0.18: fill shape with white
  740.  
  741.   gs
  742.     translate TiAngle neg rotate Tscale dup scale
  743.     flatclip pathbbox /TiBottom ed /TiRight ed /TiTop ed /TiLeft ed
  744.     TiTop TiHgt tipos TiHgt TiBottom {
  745.       gs 0 exch translate
  746.         TiLeft TiWid tipos TiWid TiRight {
  747.           gs 0 translate /TiProc load 
  748.           ArtVarsDict begin exec end gr
  749.         } for
  750.       gr
  751.     }for
  752.   gr gr
  753.   end
  754. } bd
  755.  
  756.  
  757. %--------- TEXT HANDLING -----------%
  758.  
  759.  /begintext { matrix currentmatrix } bd % leave current matrix on top of stack
  760.  /endtext { setmatrix } bd     % restore saved matrix
  761.  /ntm { exch dup setmatrix exch concat } bd % newtextmatrix: matrix
  762.  /ntmd { defmat setmatrix } bd
  763.  
  764.  /textstyle { % proc
  765.   /SimpleText? F def
  766.   /filltext exch bind def
  767.  } bd
  768.  
  769.  /plaintext { % <colour & tint>
  770.   F ovp
  771.   setcolour
  772.   /SimpleText? T def
  773.  } bd
  774.  
  775. /tf { % textfont: size width fontname
  776.   findfont 3 1 roll
  777.   exch neg matrix scale makefont
  778.   setfont
  779. } bd
  780.  
  781. /txt { % x y string
  782.   3 1 roll moveto
  783.   SimpleText?
  784.   {
  785.     Print? { show } if
  786.   }{
  787.     {
  788.       currentpoint np moveto
  789.       tempstr 0 2 index put 
  790.       tempstr T charpath filltext
  791.       pop
  792.     } forall
  793.   } ifelse
  794. } bd
  795.  
  796. /filltext { } def
  797.  
  798.  
  799. /title { 
  800.   gs
  801.   moveto
  802.   {270 rotate} if
  803.   100 pt exch div dup neg scale
  804.   /Helvetica findfont 10 scalefont setfont
  805.   show
  806.   gr
  807. } bd
  808.  
  809. /regmark {
  810.   gs translate 
  811.   1 setlinewidth
  812.   np -100 0 moveto 100 0 lineto stroke
  813.   np 0 -100 moveto 0 100 lineto stroke
  814.   np 0 0 50 0 360 arc stroke
  815.   gr
  816. } bd
  817.  
  818. /cropmark {
  819.   gs 1 setlinewidth np moveto lineto stroke gr
  820. } bd
  821.  
  822. %----- Routines to rearrange font to match Windows Ansi character set -----%
  823.  
  824. /ANSI_Vec [
  825.  /grave/acute/circumflex/tilde/macron/breve/dotaccent/dieresis
  826.  /ring/cedilla/hungarumlaut/ogonek/caron/dotlessi/.notdef/.notdef
  827.  /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
  828.  /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
  829.  /space/exclam/quotedbl/numbersign/dollar/percent/ampersand/quotesingle
  830.  /parenleft/parenright/asterisk/plus/comma/hyphen/period/slash
  831.  /zero/one/two/three/four/five/six/seven
  832.  /eight/nine/colon/semicolon/less/equal/greater/question
  833.  /at/A/B/C/D/E/F/G
  834.  /H/I/J/K/L/M/N/O
  835.  /P/Q/R/S/T/U/V/W
  836.  /X/Y/Z/bracketleft/backslash/bracketright/asciicircum/underscore
  837.  /grave/a/b/c/d/e/f/g
  838.  /h/i/j/k/l/m/n/o
  839.  /p/q/r/s/t/u/v/w
  840.  /x/y/z/braceleft/bar/braceright/asciitilde/.notdef
  841.  
  842.  /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
  843.  /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
  844.  
  845.  /.notdef/quoteleft/quoteright/quotedblleft/quotedblright/bullet/endash/emdash
  846.  /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
  847.   
  848.  /space/exclamdown/cent/sterling/currency/yen/brokenbar/section
  849.  /dieresis/copyright/ordfeminine/guillemotleft/logicalnot/hyphen/registered/macron
  850.  /degree/plusminus/twosuperior/threesuperior/acute/mu/paragraph/periodcentered
  851.  /cedilla/onesuperior/ordmasculine/guillemotright/onequarter/onehalf/threequarters/questiondown
  852.  /Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE/Ccedilla
  853.  /Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex/Idieresis
  854.  /Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis/multiply 
  855.  /Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn/germandbls
  856.  /agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla
  857.  /egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis
  858.  /eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide 
  859.  /oslash/ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis
  860. ] def
  861.  
  862.  
  863. /ReEncDict 12 dict def
  864.  
  865. /ischar {
  866.   BaseFontDict /CharStrings get exch known
  867. }bd
  868.  
  869. /mapch {
  870.   dup ischar not 
  871.   {pop /.notdef} if 
  872.   NewFont /Encoding get 3 1 roll put 
  873. }bd
  874.  
  875. /mapdegree{ 16#b0 /degree ischar {/degree}{/ring} ifelse mapch } bd
  876.  
  877. /mapbb { 16#a6 /brokenbar ischar {/brokenbar}{/bar}ifelse mapch } bd
  878.  
  879. /reencoderange {  
  880.   { dup ANSI_Vec exch get mapch } for
  881. } bd
  882.  
  883. /reencode {
  884.   0 1 15 reencoderange
  885.   144 1 255 reencoderange
  886.   16#27 /quotesingle mapch
  887.   16#60 /grave mapch
  888.   16#7C /bar mapch
  889.   mapdegree mapbb
  890. } bd
  891.  
  892. /ansifont {
  893.  ReEncDict begin
  894.    /NewFontName exch def 
  895.    /BaseFontName exch def
  896.    FontDirectory NewFontName known not
  897.    {
  898.      /BaseFontDict BaseFontName findfont def
  899.      /NewFont BaseFontDict maxlength dict def
  900.      BaseFontDict {
  901.        exch dup /FID ne { 
  902.          dup /Encoding eq { 
  903.            exch 
  904.            dup length array copy 
  905.            NewFont 3 1 roll put 
  906.          }{ 
  907.            exch 
  908.            NewFont 3 1 roll put 
  909.          }
  910.          ifelse
  911.        }{
  912.          pop pop
  913.        }ifelse
  914.      }forall
  915.      NewFont /FontName NewFontName put
  916.  
  917.      % look at the charstrings see if it has 'A' and 'Z':
  918.      % if so, remap the font. If not, leave it alone!
  919.      /A ischar /Z ischar and { reencode } if
  920.      NewFontName NewFont definefont pop
  921.    } if
  922.    NewFontName
  923.  end
  924. } bind def
  925.  
  926.  
  927. %----- Colour Separation Setup Procedures -----%
  928. %
  929. % Separation: if undefined, a composite is produced
  930. %       if numeric, a process colour separation is produced
  931. %               3=cyan, 2=magenta, 1=yellow, 0=black
  932. %       if a name of a spot colour, that spot separation is produced
  933. %
  934. % example:
  935. %       /Separation 3 def setupsep 
  936. %       /Separation /Reflex_Blue def setupsep
  937.  
  938.  
  939. /setupsep {
  940.   /Separation where {           % is 'Separation' defined?
  941.     pop
  942.     /Comp? F def                % yes: we're doing a separation.
  943.     Separation type             % is it a number?
  944.     0 type ne 
  945.     /SpotSep? ed          % if not, we're doing a spot colour.
  946.   }{
  947.     /Comp? T def                % separation not defined: doing a composite.
  948.     /SpotSep? F def
  949.   } ifelse
  950.  
  951.   statusdict begin Timeout setjobtimeout end % timeout per separation
  952.  
  953. } bd
  954.  
  955.  
  956. /setsepscreen { AngleFix add /DefScrFun load setscreen } bd
  957.  
  958.  
  959. %---------- included EPSF procedure
  960.  
  961. /include_epsf {
  962.   /Bottom ed /Left ed 
  963.   gsave concat
  964.  
  965.   % assumes that bottom-left of rect corresponds to EPSF's origin
  966.   Left Bottom translate
  967.   1000 72 div dup neg scale
  968.  
  969.   /EpsfSave save def
  970.  
  971.   /showpage { } def
  972.  
  973.   currentfile cvx stopped { % did it stop?
  974.     $error /newerror get {  % was it a new error?
  975.       handleerror           % put out an error message
  976.  
  977.       % skip to end of included file
  978.       { % loop
  979.         currentfile LineBuff readline {
  980.           (\045\045EndEPSF) eq { exit } if
  981.         }{
  982.           % can't find end marker - hit EOF?
  983.         } ifelse
  984.       } loop
  985.  
  986.     } if
  987.   }{
  988.     % didn't stop - hit EOF?
  989.   } ifelse
  990.   $error /newerror F put
  991.  
  992.   EpsfSave restore
  993.   grestore
  994. } bd
  995.  
  996. %--------------------------------- downloaded font stuff -------------------
  997.  
  998. /BuildDict 3 dict def
  999.  
  1000. /PointProcs[{}{closepath moveto}bind/lineto load/curveto load]def
  1001.  
  1002. /gst_char { gstn 8 bitshift add /gstn ed /gsti gsti 1 add def
  1003. gsti 3 eq {
  1004.   gstn 2047 and dup 1600 gt { 2048 sub } if
  1005.   gstn -11 bitshift 2047 and dup 1600 gt { 2048 sub } if
  1006.   gstn -22 bitshift 3 and PointProcs exch get exec
  1007.   /gstn 0 def /gsti 0 def
  1008.   } if
  1009. } bd
  1010.  
  1011. /gst_build { 
  1012. exch begin 
  1013.   BuildDict begin 
  1014.     Encoding exch get 
  1015.     /gstn 0 def /gsti 0 def
  1016.     dup Metrics exch get 0 setcharwidth 
  1017.     newpath CharStrings exch get { gst_char } forall 
  1018.     closepath fill 
  1019.   end 
  1020. end
  1021. } bd
  1022.  
  1023. /gst_fast { 
  1024. exch begin 
  1025.   Encoding exch get 
  1026.   dup Metrics exch get 0 setcharwidth 
  1027.   CharStrings exch get cvx exec 
  1028. end
  1029. } bd
  1030.  
  1031. /newgstfont {
  1032.   ReEncDict begin
  1033.   /NewFontSize ed
  1034.   /NewFontId ed
  1035.   /NewFontFast ed
  1036.   /NewFontName ed
  1037.   10 dict dup begin
  1038.     /FontMatrix [ .001 0 0 .001 0 0 ] def
  1039.     /FontType 3 def
  1040.     /FontBBox [ -400 -300 1600 1000 ] def
  1041.     /Encoding ANSI_Vec def
  1042.     /Metrics NewFontSize dict def Metrics /.notdef 0 put
  1043.     /CharStrings NewFontSize dict def CharStrings /.notdef () put
  1044.     /UniqueID 16#ff0000 NewFontId add def
  1045.     /gst_fast /gst_build NewFontFast { exch } if load /BuildChar ed pop
  1046.   end
  1047.   NewFontName exch definefont pop
  1048.   NewFontName
  1049. end
  1050. } bd
  1051.     
  1052. /NewCharDict 4 dict def
  1053.  
  1054. /newchar { 
  1055. NewCharDict begin
  1056.   /Proc ed
  1057.   /Wid ed
  1058.   /Code ed
  1059.   dup findfont begin
  1060.     Encoding Code get dup
  1061.     CharStrings exch /Proc load put
  1062.     Metrics exch Wid put
  1063.   end
  1064. end
  1065. } bd
  1066.  
  1067.  
  1068. %%EndProlog
  1069.  
  1070. %%BeginSetup
  1071.  
  1072. /ArtworkSave save def
  1073.   ArtVarsDict begin
  1074.  
  1075.   % boolean abbreviations
  1076.   /T true def /F false def
  1077.  
  1078.   % initialise default line end, join, mitre limit etc
  1079.   1 1 14 sline 10 sml
  1080.  
  1081.   % initialise misc variables
  1082.   /tempstr 1 string def         % buffer for text
  1083.   /ImageBuff 1 string def       % buffer for bitmap images
  1084.   /ImageRgbBuff 3 string def    % buffer for bitmap images
  1085.   /LineBuff 256 string def      % buffer for included epsfs
  1086.   /SimpleText? T def            % flag for fast text handling
  1087.   /Wind? T def                  % winding fill on/off
  1088.   /Print? T def                 % print flag used by colour separation stuff
  1089.   /SaveCmyk 4 array def         % current C,M,Y,K colour
  1090.   /Imat matrix identmatrix def  % an indentity matrix
  1091.   /bignum 2 31 exp 1 sub def    % for random number generator
  1092.   initcmykcolor
  1093.  
  1094.   % determine current transformation's rotation, (eg for landscape)
  1095.   % which will need to be applied to any screen angles
  1096.   /AngleFix 1 0 dtransform exch atan def
  1097.  
  1098.   % record the current screen function, angle and frequency
  1099.   currentscreen /DefScrFun exch def pop pop
  1100.   ArtProcsDict /Screens known {
  1101.     currentscreen Screens exch 0 exch put pop pop
  1102.   } if
  1103.  
  1104.   % record the current transfer function, and set up a normalised
  1105.   % transfer function followed by the default
  1106.   /DefTran currenttransfer def
  1107.   {normalise DefTran}bind settransfer
  1108.  
  1109.  
  1110. %%EndSetup
  1111.  
  1112. %%Trailer
  1113. end % ArtVarsDict
  1114. ArtworkSave restore
  1115. end % ArtProcsDict
  1116. %%EOF
  1117.  
  1118.  
  1119.